//--------------------------------------------------------------------//
// Do-file: 02_main_results 
//
// Paper: "Mano Dura: An Experimental Evaluation of Military Policing in Cali, 
// Colombia"
//
// Authors: Robert Blair, Lucia Mendoza-Mora, and Michael Weintraub
//
// Date last modified: 2024-12-19
// 
// Notes:
// (1) This code replicates the tables and figures included in the main section
// of the paper.
//
//--------------------------------------------------------------------//


			/////////////////////////////////
			//                             //
			//-- Main tables and figures --//
			//                             //
			/////////////////////////////////
			
					
//---------//
// -- Preliminaries 
//---------//

clear all
set more off
graph set window fontface "Times New Roman"

* Defining main computer path
global path "[YOUR DIRECTORY]" 
		
* Set working directory
cd "${path}" 

* Set globarl vars
global demovars age gender educ 
global blockdemovars block_age block_educ block_pct_male 
global geovars number_buildings_sampling area bat_min cai_min ptr_min 
		
		
	
			//---------------------------------------------------------//
			//-- Table 1: Treatment effects on attitudes towards the --//
			// police and military and demand for military policing    //
			//---------------------------------------------------------//

//----//								 
//- Regressions with endline data	
//----//				
				
//- Load data (endline)
					
	use "data/survey_endline.dta", clear


//-- Column 1 (perceptions of the police)

	reg i_legitp  i.treatment i.barrio_code ${demovars} ${geovars} [pweight=iweight], ///
		vce(cluster manzana_code) baselevels
	
	qui sum i_legitp  if control==1 
	estadd scalar c_mean = r(mean), replace
	
	estimates store lpol_a
	
					 
//-- Column 2 (perceptions of the military)	

	reg i_legitm  i.treatment i.barrio_code ${demovars} ${geovars} [pweight=iweight], ///
		vce(cluster manzana_code) baselevels
	
	qui sum i_legitm  if control==1 
	estadd scalar c_mean = r(mean), replace
	
	estimates store lmil_a
	

//----//								 
//- Regressions with behavioral addition of endline data	
//----//				

	use "data/behavioral_data.dta", clear
	
	
//-- Column 3 (demand for the military)	

	reg num_report i.treatment i.barrio_code ${blockdemovars} ${geovars} [pweight = iweight], baselevels
	
	qui sum num_report  if treatment == 0
	estadd scalar c_mean = r(mean), replace
	
	estimates store bha
	

//-- Export the regressions --//
	
	loc var1 `"\textbf{\shortstack{Perceptions of \\ police}}"'
	loc var2 `"\textbf{\shortstack{Perceptions of \\ military}}"'
	loc var3 `"\textbf{\shortstack{Demand for \\ military}}"'

	esttab lpol_a lmil_a bha ///
		using "results\ITT_perceptions_demand.tex", ///
		legend booktabs f replace b(%9.3fc) se(%9.3fc) ///
		order(1.treatment 2.treatment) compress ///
		indicate("Individual-level controls = ${demovars}" "Block-level controls = ${geovars}" "Neighborhood FE = *.barrio_code", labels("\checkmark" "\xmark")) ///					
		keep(1.treatment 2.treatment) ///
		stats(N r2 c_mean, fmt(0 3 3)  labels("Observations" "\$R^2$" "Control mean")) ///
		label nonotes nonum nodepvar nogaps mtitle(`"`var1'"' `"`var2'"' `"`var3'"')  ///
		star(\textsuperscript{\textdagger} 0.10 * 0.05 ** 0.01)								///
		prehead(  																			///
		   \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}										///				   
		   \begin{tabular}{@{\extracolsep{4pt}}l*{@M}{c}@{}} 								/// 
		   \hline \hline                                    								///
			\noalign{\smallskip}															///			   
		   & \multicolumn{2}{c}{\textbf{Survey data}}		   							///
		   & \textbf{Behavioral data} \\ 									///
			\noalign{\smallskip}															///			   						
			\cline{2-3} \cline{4-4} \addlinespace			 											///
	   )  																							///
	   posthead(\addlinespace									///
			\hline												///
			\addlinespace										///
	   )		 												///
	   postfoot(  												///
		  \noalign{\smallskip} \hline \hline  					///
		  \end{tabular} 										///
		  \medskip     											///
	   )	

	   

		    //-------------------------------------------------//
		    //--  Table 2: Treatment effects on turnout for  --//
		    //		       right-wing candidates  		     --//
		    //-------------------------------------------------//
				
//----//								 
//- Regressions with endline data	
//----//				
				
//-- Load data (endline)
					
	use "data/survey_endline.dta", clear

	
//-- Column 1 (turnout for conservative candidates - all)	

	reg political_ideology1  i.treatment i.barrio_code ${demovars} ${geovars} [pweight=iweight], ///
		vce(cluster manzana_code) baselevels
	
	qui sum political_ideology1  if treatment == 0
	estadd scalar c_mean = r(mean), replace	
	
	estimates store vote1
	
	
//------//	
//-- Export regressions -original format
//------//
	
		loc p1 "All"
				
		esttab vote1  ///
			using "results\ITT_turnout_conservative.tex", ///
			legend booktabs f replace b(%9.3fc) se(%9.3fc) ///
			order(treatment spillover) compress ///
			indicate("Individual-level controls = ${demovars}" "Block-level controls = ${geovars}" "Neighborhood FE = *.barrio_code", labels("\checkmark" "\xmark")) ///
			keep(1.treatment 2.treatment) ///
			stats(N r2 c_mean, fmt(0 3 3 3) labels("Observations" "\$R^2$" "Control mean")) ///
			label nonotes nonum nodepvars nogaps mtitle(`"`p1'"') ///
			star(\textsuperscript{\textdagger} 0.10 * 0.05 ** 0.01)	 ///
			prehead(  																		///
		   \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}										///				   
		   \begin{tabular}{@{\extracolsep{4pt}}l*{@M}{c}@{}} 								/// 
		   \hline \hline                                    								///
			\noalign{\smallskip}															///			   
		   & \multicolumn{1}{c}{\textbf{Survey data}} \\ 									///
			\noalign{\smallskip}															///			   						
			\cline{2-2} \addlinespace			 											///
			&  \multicolumn{1}{c}{\textbf{\shortstack{Turnout for \\ conservative \\ candidates}}}  \\			///
			\noalign{\smallskip}																	///
			\cline{2-2} \addlinespace													///
	   )  																							///
	   posthead(\addlinespace									///
			\hline												///
			\addlinespace										///
	   )		 												///
	   postfoot(  												///
		  \noalign{\smallskip} \hline \hline  					///
		  \end{tabular} 										///
		  \medskip     											///
	   )	
	   	   

		   
			//--------------------------------------------------------//
			//-- Table 3: Treatment effects on support for military --//
			//       coups and extrajudicial punishment		   		  //
			//--------------------------------------------------------//

//----//								 
//- Regressions with endline data	
//----//				
				
//-- Load data (endline)
					
	use "data/survey_endline.dta", clear	
			

//-- Column 1 (supports military coups in response to crime)	

	reg attitudes_milicoup_crime  i.treatment i.barrio_code ${demovars} ${geovars} [pweight=iweight], ///
		vce(cluster manzana_code) baselevels
	
	qui sum attitudes_milicoup_crime  if treatment == 0
	estadd scalar c_mean = r(mean), replace
	
	estimates store coup1	
	
	
//-- Column 2 (supports military coups in response to corruption)

	reg attitudes_milicoup_corr  i.treatment i.barrio_code ${demovars} ${geovars} [pweight=iweight], ///
		vce(cluster manzana_code) baselevels
	
	qui sum attitudes_milicoup_corr  if treatment == 0
	estadd scalar c_mean = r(mean), replace
	
	estimates store coup2


//-- Column 3 (survey support for vigilantism)	
		
	reg attitudes_lawenforcement_std  i.treatment i.barrio_code ${demovars} ${geovars} [pweight=iweight], ///
		vce(cluster manzana_code) baselevels
	
	qui sum attitudes_lawenforcement_std  if treatment == 0
	estadd scalar c_mean = r(mean), replace
	
	estimates store vigi

		
//-- Column 4 (survey support for bypassing the police)

	reg attitudes_commpunish_std  i.treatment i.barrio_code ${demovars} ${geovars} [pweight=iweight], ///
		vce(cluster manzana_code) baselevels
	
	qui sum attitudes_commpunish_std  if treatment == 0
	estadd scalar c_mean = r(mean), replace
	
	estimates store byp_pol

	
//-- Export the regressions --//
	
	loc var1 "\textbf{\shortstack{In response \\ to crime}}"
	loc var2 "\textbf{\shortstack{In response \\ to corruption}}"
	loc var3 "\textbf{\shortstack{Bypassing the\\ legal system}}"
	loc var4 "\textbf{\shortstack{Bypassing the\\ police}}"

	esttab coup1 coup2 vigi byp_pol ///
		using "results\ITT_vigilante_coups.tex", ///
		legend booktabs f replace b(%9.3fc) se(%9.3fc) ///
		order(1.treatment 2.treatment) compress ///
		indicate("Individual-level controls = ${demovars}" "Block-level controls = ${geovars}" "Neighborhood FE = *.barrio_code", labels("\checkmark" "\xmark")) ///					
		keep(1.treatment 2.treatment) ///
		stats(N r2 c_mean, fmt(0 3 3)  labels("Observations" "\$R^2$" "Control mean")) ///
		label nonotes nonum nodepvar nogaps mtitle(`"`var1'"' `"`var2'"' `"`var3'"' `"`var4'"')  ///
		star(\textsuperscript{\textdagger} 0.10 * 0.05 ** 0.01)								///
		prehead(  																			///
		   \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}										///				   
		   \begin{tabular}{@{\extracolsep{4pt}}l*{@M}{c}@{}} 								/// 
		   \hline \hline                                    								///
			\noalign{\smallskip}															///			   
		   & \multicolumn{4}{c}{\textbf{Survey data}} \\ 									///
			\noalign{\smallskip}															///
			\cline{2-5} \addlinespace			 											///
			&  \multicolumn{2}{c}{\textbf{\shortstack{Support for military coups}}}		///
			&  \multicolumn{2}{c}{\textbf{\shortstack{Support for vigilantism}}}  \\			///
			\cline{2-3} \cline{4-5} \addlinespace	///
	   )  																							///
	   posthead(\addlinespace									///
			\hline												///
			\addlinespace										///
	   )		 												///
	   postfoot(  												///
		  \noalign{\smallskip} \hline \hline  					///
		  \end{tabular} 										///
		  \medskip     											///
	   )	

	   
	   
			//----------------------------------------------------------//
			//-- Figure 4: treatment effects on perceptions of police --//
			// 		 and military using conjoint experiment    		    //
			//----------------------------------------------------------//

//-------//
//-- Regressions with endline data (conjoint experiment)
//-------//
				
	use "data/conjoint_data.dta", clear
	
	
//-- Conjoint experiment 
		
	reg conjoint_stdin $demovars $geovars treatment##(r_profile_u r_profile_g) ///
				 i.barrio_code [pweight = iweight], vce(cluster key) baselevels 
	
	estadd matrix table = r(table)
	eststo cjoint, title("Index")	
	

//------//					 
//-- Coefplot of all regressions (with normal p-values)
//------//	
						 		
//-- Make the coefplot 
	
	#delim ;				
	coefplot cjoint, bylab("Conjoint Index") || , 		
					 drop(*barrio* _cons 0.treatment 1.treatment 2.treatment $demovars $geovars) xline(0, lpattern(dash) lwidth(vthin) lcolor(black)) 	
					 headings(0.r_profile_uniform = "{bf: Uniform}" 
							  0.r_profile_gun = "{bf: Weapon}"
							  0.treatment#0.r_profile_uniform = "{bf: Treatment status × uniform}"
							  0.treatment#0.r_profile_gun = "{bf: Treatment status × weapon}",
							  labsize(small))
					coeflabel(0.r_profile_uniform = "Police"
							  1.r_profile_uniform = "Military" 
							  0.r_profile_gun = "Pistol"
							  1.r_profile_gun = "Rifle"
							  0.treatment#0.r_profile_uniform = "Control × police"
							  1.treatment#1.r_profile_uniform = "Treatment × military"
							  2.treatment#1.r_profile_uniform = "Spillover × military"
							  0.treatment#0.r_profile_gun = "Control × pistol"
							  1.treatment#1.r_profile_gun = "Treatment × rifle"
							  2.treatment#1.r_profile_gun = "Spillover × rifle",
							  labsize(small)) 
					mlabel("{it:p} = " + string(@pval,"%9.3f"))	
					xtitle("Average marginal component effect") scheme(plotplainblind) color(black)
					graphregion(fcolor(white)) ciopts(lcolor(black)) msize(small) msymbol(circle) baselevels  
					xlabel(.2 .4 .6 .8 1. 1.2, nogrid) xscale(range(-0.05 1.2) on extend) /// 
					ylabel(, nogrid) grid(none) ///
					mlabcolor(none) addplot(scatter @at @ul, ms(i) mlabel(@mlbl) mlabcolor(black))					
					; 
			#delim cr			

graph export "results/conjoint_AMCEs_pvals.pdf", replace	


	   
	   
	   

	   
